 <?php  
 //pr($mailData);
echo $this->session->flash(); 
if(!empty($mailData)){
    $this->Paginator->options(array(
        'update' => '#divUpdate',
        'evalScripts' => true,
        'url' => array('controller' => 'Payrolls', 'action' => 'email_history')
    ));
} ?>
<div class="file" id="List">
    <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#686550">
        <tr class="heading"  bgcolor="#708089">
            <td width="6%" valign="top" align="left"><?php echo __('S.NO') ?></td>
            <td valign="top"  align="left"><?php echo $this->Paginator->sort('created', __('DATE_SENT', true)); ?></td>
            <td valign="top"  align ="left"><?php echo $this->Paginator->sort('sent_by', __('SENT_BY', true)); ?></td>
            <td valign="top"  align ="left"><?php echo __('EMAIL_TYPE'); ?></td>
            <td valign="top"  align="left"><?php echo __('ACTION'); ?></td>
        </tr>
        <?php
        if (isset($mailData) && count($mailData) > 0) {
            $i = 0;
            foreach ($mailData as $arrayDetail) {
                ?>
                <tr class="heading2" bgcolor="#ffffff">
                    <td>&nbsp;<?php echo $i + 1 ?></td>
                    <td>&nbsp;<?php echo date('M j, Y', strtotime($arrayDetail['Mail']['created'])); ?></td>
                    <td>&nbsp;<?php echo $userData[$arrayDetail['Mail']['sent_by']]; ?></td>
                    <td>&nbsp;<?php echo __('PART_TIME_PAYROLL_STATUS'); ?></td>
                    <td>
                        <?php
                            if(!$roleId || $showLinkEmailHistoryDetailURL){//No checks for superadmin
                                /*echo $this->html->link($this->Html->image('icons/16/icon_view.gif'), array(
                                    'controller' => 'payrolls',
                                    'action' => 'view_email_history',
                                    $arrayDetail['Mail']['id']), array(
                                    'alt' => __('EDIT', true),
                                    'title' => __('EDIT', true),
                                    'escape'=>false)
                                );*/
                                
                                echo $this->Html->link(
                                        $this->Html->image('icons/16/icon_view.gif', array("alt" => "eBox")), '#', array(
                                        'target' => '_blank',
                                        'escape' => false,
                                        'onClick' => "window.open('".$this->Html->url(array(
                                            'controller' => 'payrolls',
                                            'action' => 'check_email_history/'.$arrayDetail['Mail']['id'],
                                        ))."', 'windowname','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=500'); return false;"
                                    ));
                            }
                        ?>
                    </td>
                </tr>  
                <?php
                $i++;
            }
        }
        ?>
        <tr>
            <td colspan="5" bgcolor="#ffffff" align="center">
                <div class="pagination">            
                    <?php
                    if (!empty($mailData)) {
                        echo $this->Element('pagination');
                    } else {
                        echo __("NO_RECORD_MESSAGE");
                    }
                    ?>              
                </div>
            </td>
        </tr>

        <tr bgcolor="#ffffff">
            <td colspan="5" valign="top">
                <table width="30%">
                    <tr>
                        <td width="10%">
                            <b><?php echo __('LEGENDS') ?> :- </b> 
                        </td>
                        <td width="20%">
                            <?php echo $this->html->image('/img/icons/16/icon_view.gif'); ?>
                            <?php echo __('VIEW') ?>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
<?php echo $this->Js->writeBuffer();?>